package com.nx.filter.sql92;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import com.nx.Constant;
public class FilterProducer {


    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("filter_sample_group");
        producer.setNamesrvAddr(Constant.MQ);
        producer.setSendMsgTimeout(10 * 1000);
        producer.start();

        for (int i = 0; i < 10; i++) {
            Message msg = new Message("nx-user-filter",
                    "TAG-FILTER",
                    ("Hello RocketMQ " + i).getBytes(RemotingHelper.DEFAULT_CHARSET)
            );
            msg.putUserProperty("a",String.valueOf(i));
            if(i % 2 == 0){
                msg.putUserProperty("b","bigdata");
            }else{
                msg.putUserProperty("b","java");
            }
            producer.send(msg);
        }

        producer.shutdown();
    }

}
